<template>
  <div>
    <!--确认弹出框  -->
    <CommonDialog
      title="确认"
      width="30%"
      v-bind:dialogVisible="applicationDialogVisible"
      @on-change-dialogVisible="applicationChange"
      class="confirm"
      top="10vh"
    >
      <template #body>
        <div class="confirmTitle">
          下一步要做的事情
        </div>
        <el-select v-model="stageValue" filterable placeholder="请选择" class="confirmSelect" clearable>
          <el-option v-for="(item, index) in childStageList" :key="index" :label="item.name" :value="item.id">
          </el-option>
        </el-select>
      </template>
      <template #dialog_footer>
        <el-button @click="Cancel">取 消</el-button>
        <el-button type="primary" @click="confirm">确认</el-button>
      </template>
    </CommonDialog>
  </div>
</template>

<script>
/* 引入通用的弹出框 */
import CommonDialog from '@/components/commonDialog/commonDialog.vue'
import { FeedBack } from '@/api/feedBack/server'
export default {
    name: '',
    components: {
        CommonDialog
    },
    props: {},
    data() {
        return {
            applicationDialogVisible: false,
            childStageList: [],
            stageValue: '1425006410613207042'
        }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {
        this.getChildStageList()
    },
    methods: {
        // 确认模态框数据加载
        show(id) {
            this.id = id
            this.applicationDialogVisible = true
        },
        // 获取阶段列表
        async getChildStageList() {
            try {
                const result = await FeedBack.GetListChildrenAsync({ type: 'NAME' })
                if (result.success) {
                    const data = JSON.parse(JSON.stringify(result.data))
                    const arr = []
                    for (var i = 0; i < data.length; i++) {
                        const item = data[i]
                        if (
                            item.id != '1423154037607493634' &&
              item.id != '1423154076169924610' &&
              item.id != '1423154128091213825'
                        ) {
                            arr.push(item)
                        }
                    }
                    this.childStageList = arr
                }
            } catch (err) {
                console.log(err)
            }
        },
        // 关闭模态框
        applicationChange() {
            this.applicationDialogVisible = false
            this.stageValue = '1425006410613207042'
        },
        // 取消按钮
        Cancel() {
            this.applicationDialogVisible = false
            this.stageValue = '1425006410613207042'
        },
        // 确认按钮
        confirm() {
            console.log(this.stageValue)
            if (this.stageValue != null && this.stageValue != '') {
                const objParmars = {
                    id: this.id,
                    stage: this.stageValue,
                    operationType: 1
                }
                this.confirmOptionAsync(objParmars)
            } else {
                this.$message.error('请选择阶段')
            }
        },
        // 确认函数调用
        async confirmOptionAsync(parmars) {
            try {
                const result = await FeedBack.OperationAsync(parmars)
                if (result.success) {
                    this.$message.success('已确认')
                    this.applicationDialogVisible = false
                    this.$emit('refreshPage')
                }
            } catch (error) {
                console.log(error)
            }
        }
    }
}
</script>

<style scoped lang="less">
::v-deep .confirm .el-dialog__body {
  height: 130px;
}

.confirmTitle {
  margin-right: 20px;
  font-size: 14px;
  margin-bottom: 10px;
}
</style>
